package com.lailai.constant;

/**
 * @Author lgr
 * @Date 2025/9/15
 * @Email 983105834@qq.com
 */
public enum DataType {
    SHORT_STRING(0, "短文本"),
    STRING(1, "长文本"),
    SINGLE_SELECT(2, "单选文本"),
    MULTI_SELECT(3, "多选文本"),
    BOOL(4, "布尔"),
    DATETIME(5, "日期"),
    DECIMAL(6, "数值"),
    ADDRESS(7, "地址"),
    LOCATION(8, "地图"),
    USER(9, "人员单选"),
    MULTI_USER(10, "人员多选"),
    DEPARTMENT(11, "部门单选"),
    MULTI_DEPARTMENT(12, "部门多选"),
    FILE(13, "附件"),
    IMAGE(14, "图片"),
    REFERENCE(15, "关联数据"),
    MULTI_REFERENCE(16, "关联多选"),
    SIGNATURE(17, "签名");
    private int index;
    private String name;

    private DataType(int index, String name) {
        this.name = name;
        this.index = index;
    }

    public static String getName(int index) {
        for (DataType dataType : values()) {
            if (dataType.index == index) {
                return dataType.name;
            }
        }

        return null;
    }

    public static DataType get(int index) {
        for (DataType dataType : values()) {
            if (dataType.index == index) {
                return dataType;
            }
        }

        return null;
    }
}
